interface IAuthType {
  token: string;
}

const AUTH_KEY = 'userToken';
export const saveAuth = (auth: IAuthType) => {
  localStorage.setItem(AUTH_KEY, JSON.stringify(auth));
};

export const getAuth = (): IAuthType => {
  return JSON.parse(localStorage.getItem(AUTH_KEY) || '{}');
};

export const removeAuth = () => {
  localStorage.removeItem(AUTH_KEY);
};

export const hasToken = () => {
  return !!getAuth().token;
};
